package 算法.leetcode.offer;

import 算法.leetcode.offer.base.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lchenglong
 * @date 2022/3/19
 */
public class Offer55_I {

    public static void main(String[] args) {
        Offer55_I instance = new Offer55_I();
        // 3,9,20,null,null,15,7
        List<Integer> list = new ArrayList<Integer>();
        list.add(3);
        list.add(9);
        list.add(20);
        list.add(null);
        list.add(null);
        list.add(15);
        list.add(7);
        TreeNode root = TreeNode.init(list);
        int depth = instance.maxDepth(root);
        System.out.println(depth);

    }
    int depth = 0;
    public int maxDepth(TreeNode root) {
        if (root == null) return 0;
        return Math.max(maxDepth(root.left),maxDepth(root.right)) +1;
    }


}
